home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Sample.bin / ExampleLauncher.java < prev    next >
Text File  |  1998-09-28  |  5KB  |  165 lines

  1. /*
  2.         A basic implementation of the JFrame class.
  3. */
  4.  
  5. import com.sun.java.swing.*;
  6. import java.awt.*;
  7.  
  8. public class ExampleLauncher extends com.sun.java.swing.JFrame
  9. {
  10.     String driver=null;
  11.     String url=null;
  12.     String user=null;
  13.     String password=null;
  14.     String query=null;
  15.     
  16.     public ExampleLauncher()
  17.     {
  18.         // This code is automatically generated by Visual Cafe when you add
  19.         // components to the visual environment. It instantiates and initializes
  20.         // the components. To modify the code, only use code syntax that matches
  21.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  22.         // parse your Java file into its visual environment.
  23.         //{{INIT_CONTROLS
  24.         setTitle("Select Table Example");
  25.         setDefaultCloseOperation(com.sun.java.swing.JFrame.DISPOSE_ON_CLOSE);
  26.         getContentPane().setLayout(new BoxLayout(this.getContentPane(),BoxLayout.Y_AXIS));
  27.         getContentPane().setFont(new Font("Dialog", Font.PLAIN, 0));
  28.         setSize(164,138);
  29.         setVisible(false);
  30.         example1.setText("Example1");
  31.         example1.setActionCommand("Example1");
  32.         example1.setAlignmentX(0.5F);
  33.         getContentPane().add(example1);
  34.         example1.setBounds(36,0,91,25);
  35.         example2.setText("Example 2");
  36.         example2.setActionCommand("Example 2");
  37.         example2.setAlignmentX(0.5F);
  38.         getContentPane().add(example2);
  39.         example2.setBounds(35,25,93,25);
  40.         example3.setText("Example 3");
  41.         example3.setActionCommand("Example 3");
  42.         example3.setAlignmentX(0.5F);
  43.         getContentPane().add(example3);
  44.         example3.setBounds(35,50,93,25);
  45.         example4.setText("Example 4");
  46.         example4.setActionCommand("Example 4");
  47.         example4.setAlignmentX(0.5F);
  48.         getContentPane().add(example4);
  49.         example4.setBounds(35,75,93,25);
  50.         //}}
  51.  
  52.         //{{INIT_MENUS
  53.         //}}
  54.     
  55.         //{{REGISTER_LISTENERS
  56.         SymAction lSymAction = new SymAction();
  57.         example1.addActionListener(lSymAction);
  58.         example2.addActionListener(lSymAction);
  59.         example3.addActionListener(lSymAction);
  60.         example4.addActionListener(lSymAction);
  61.         //}}
  62.     }
  63.  
  64.     static public void main(String args[])
  65.     {
  66.         ExampleLauncher e = new ExampleLauncher();
  67.         e.setLocation(50, 50);
  68.         e.setVisible(true);
  69.     }
  70.  
  71.     //{{DECLARE_CONTROLS
  72.     com.sun.java.swing.JButton example1 = new com.sun.java.swing.JButton();
  73.     com.sun.java.swing.JButton example2 = new com.sun.java.swing.JButton();
  74.     com.sun.java.swing.JButton example3 = new com.sun.java.swing.JButton();
  75.     com.sun.java.swing.JButton example4 = new com.sun.java.swing.JButton();
  76.     //}}
  77.  
  78.     //{{DECLARE_MENUS
  79.     //}}
  80.  
  81.     void configDialog(SimpleJdbcTableModel tm)
  82.     {
  83.         JdbcConfigurationDialog config = new JdbcConfigurationDialog(this, true);
  84.         if(driver==null)
  85.         {
  86.             config.setDriver(tm.getJdbcDriverClass());
  87.             config.setURL(tm.getJdbcDriverURL());
  88.             config.setUser(tm.getUser());
  89.             config.setPassword(tm.getPassword());
  90.             config.setQuery(tm.getQuery());
  91.         }
  92.         else
  93.         {
  94.             config.setDriver(driver);
  95.             config.setURL(url);
  96.             config.setUser(user);
  97.             config.setPassword(password);
  98.             config.setQuery(query);
  99.         }
  100.         config.setVisible(true);
  101.         
  102.         driver = config.getDriver();
  103.         url = config.getURL();
  104.         user = config.getUser();
  105.         password = config.getPassword();
  106.         query = config.getQuery();
  107.         
  108.         tm.setJdbcDriverClass(driver);
  109.         tm.setJdbcDriverURL(url);
  110.         tm.setUser(user);
  111.         tm.setPassword(password);
  112.         tm.setQuery(query);
  113.         tm.doQuery();
  114.     }
  115.  
  116.     class SymAction implements java.awt.event.ActionListener
  117.     {
  118.         public void actionPerformed(java.awt.event.ActionEvent event)
  119.         {
  120.             Object object = event.getSource();
  121.             if (object == example1)
  122.                 example1_actionPerformed(event);
  123.             else if (object == example2)
  124.                 example2_actionPerformed(event);
  125.             else if (object == example3)
  126.                 example3_actionPerformed(event);
  127.             else if (object == example4)
  128.                 example4_actionPerformed(event);
  129.         }
  130.     }
  131.  
  132.     void example1_actionPerformed(java.awt.event.ActionEvent event)
  133.     {
  134.         TableExample1 te = new TableExample1();
  135.         configDialog(te.simpleJdbcTableModel1);
  136.         te.setLocation(getLocation().x + 30, getLocation().y + 30);
  137.         te.setVisible(true);
  138.         dispose();
  139.     }
  140.  
  141.     void example2_actionPerformed(java.awt.event.ActionEvent event)
  142.     {
  143.         TableExample2 te = new TableExample2();
  144.         configDialog(te.simpleJdbcTableModel1);
  145.         te.setLocation(getLocation().x + 30, getLocation().y + 30);
  146.         te.setVisible(true);
  147.         dispose();
  148.     }
  149.  
  150.     void example3_actionPerformed(java.awt.event.ActionEvent event)
  151.     {
  152.         TableExample3 te = new TableExample3();
  153.         te.setLocation(getLocation().x + 30, getLocation().y + 30);
  154.         te.setVisible(true);
  155.         dispose();
  156.     }
  157.  
  158.     void example4_actionPerformed(java.awt.event.ActionEvent event)
  159.     {
  160.         TableExample4 te = new TableExample4();
  161.         te.setLocation(getLocation().x + 30, getLocation().y + 30);
  162.         te.setVisible(true);
  163.         dispose();
  164.     }
  165. }